import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
@WebServlet("/Servlet1")
public class Servlet1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        resp.setCharacterEncoding("UTF-8");
        ArrayList<Product> list = new ArrayList<>();
        list.add(new Product("广东","华为","新品","手机",200,500,"image/1.jpg"));
        list.add(new Product("深圳","诺基亚","新品","诺基亚",200,500,"image/2.jpg"));
        list.add(new Product("广东","华为","新品","手机",3000,1000,"image/3.jpg"));
        list.add(new Product("广东","华为","新品","手机",2030,2200,"image/4.jpg"));
        list.add(new Product("广东","华为","新品","手机",2010,5650,"image/5.jpg"));
        list.add(new Product("广东","华为","新品","手机",2050,200,"image/6.jpg"));
        list.add(new Product("广东","华为","新品","手机",1100,2600,"image/7.jpg"));
        list.add(new Product("广东","华为","新品","手机",3300,4400,"image/8.jpg"));

        req.setAttribute("list", list);
        req.getRequestDispatcher("index.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
